package sunyu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import sunyu.view.ExcelView;

import java.util.*;

/**
 * @author 孙宇
 */
@Controller
@RequestMapping("/export")
public class ExportController extends CommonController {

    @RequestMapping("/excel")
    public ModelAndView excel() {
        List<Map> data = new ArrayList<>();//假设这个地方是你从service查询出来的结果
        //这里就先模拟一下数据
        data.add(new HashMap() {{
            put("id", "1");
            put("name", "孙宇");
            put("gz", "100.13");
            put("day", new Date());
        }});
        data.add(new HashMap() {{
            put("id", "2");
            put("name", "孙宇2");
            put("gz", "10000.13");
            put("day", new Date());
        }});
        data.add(new HashMap() {{
            put("id", "3");
            put("name", "孙宇3");
            put("gz", "10550.13");
            put("day", new Date());
        }});

        Map model = new HashMap();
        model.put("list", data);

        return new ModelAndView(new ExcelView(), model);
    }

}
